#ifndef LPR_INFER_API_H
#define LPR_INFER_API_H
#include <iostream>
#include <vector>
#include <numeric>
#include <chrono>
#include <opencv2/opencv.hpp>

class DetectRecPlate
{
    public:
        DetectRecPlate();
        ~DetectRecPlate();
        virtual void infer(cv::Mat &img, std::string &plate_number, float &plate_char_conf, std::string &plate_color, std::vector<float>& char_conf) = 0;

        cv::Mat get_split_merge(cv::Mat &img);

    protected:
        
        //识别模型参数
        const std::string rec_model_path = "./model/plate_rec_color_conf";
        std::string rec_input_name = "images"; //识别模型 onnx 输入  名字
        std::string  rec_output_name= "output"; //识别模型 onnx 输出 名字
        int plate_rec_input_w = 168;
        int plate_rec_input_h = 48;  
        float mean_value = 0.588;
        float std_value = 0.193;
        // stuff we know about the network and the input/output blobs
        const std::vector<std::string> plate_string={"#","京","沪","津","渝","冀","晋","蒙","辽","吉","黑","苏","浙","皖", \
        "闽","赣","鲁","豫","鄂","湘","粤","桂","琼","川","贵","云","藏","陕","甘","青","宁","新","学","警","港","澳","挂","使","领","民","航","深", \
        "0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z"};

        const std::vector<std::string> plate_string_yingwen={"#","<beijing>","<hu>","<tianjin>","<chongqing>","<hebei>","<jing>","<meng>","<liao>","<jilin>","<hei>","<su>","<zhe>","<wan>", \
        "<fujian>","<gan>","<lun>","<henan>","<hubei>","<hunan>","<yue>","<guangxi>","<qiong>","<chuan>","<guizhou>","<yun>","<zang>","<shanxi>","<gan>","<qinghai>",\
        "<ning>","<xin>","<xue>","<police>","<hongkang>","<Macao>","<gua>","<shi>","<ling>","<min>","<hang>","<shen>", \
        "0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z"};

        const std::vector<std::string> plate_color_string={"黑","蓝","绿","白","黄"};

        void blobFromImage_plate(cv::Mat& img,float mean_value,float std_value,float *blob);
        void decode_outputs(float *prob,int output_size,  std::string &plate, float &plate_char_conf, std::vector<float>& char_conf);
        std::string decode_color_outputs(float *prob,int output_size);
        void get_plate_result(cv::Mat &img,std::string &plate_number, float &plate_char_conf, std::string &plate_color, std::vector<float>& char_conf);
};

std::shared_ptr<DetectRecPlate> CreateDrpApp();

#endif
